package com.netbetter.langzheng.plugin.fileManager.widget.property;

import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.netbetter.langzheng.plugin.fileManager.context.ChangeListItemEventContext;
import com.netbetter.langzheng.plugin.fileManager.context.EventUtils;
import com.netbetter.langzheng.plugin.fileManager.model.FileModel;
import com.netbetter.langzheng.plugin.fileManager.widget.LangzhengTextField;

/**
 * @author 嘉陵江里捉鱼 E-mail:tang7259@163.com
 * @Date 创建时间：2008-9-6 下午04:05:32 类说明
 */
public class FolderPropertyDialog extends PropertyDialog {

    private TabItem                    normalTabl;
    private TabItem                    shareTabl;
    private TextField<String>          nameText;
    private LangzhengTextField<String> pathLable;
    private LangzhengTextField<String> infoLable;

    public FolderPropertyDialog() {
        super();
        panel.setFrame(false);
        panel.setHeaderVisible(false);
        panel.setBodyBorder(false);
        panel.setButtonAlign(HorizontalAlignment.CENTER);
        panel.setLayout(new FitLayout());

        TabPanel tabs = new TabPanel();

        normalTabl = new TabItem();
        normalTabl.setLayout(new FormLayout());
        normalTabl.setText("常规");
        nameText = new TextField<String>();
        nameText.setFieldLabel("名称");

        normalTabl.add(nameText);

        LangzhengTextField<String> typeLable = new LangzhengTextField<String>();
        typeLable.setFieldLabel("类型");
        typeLable.setValue("文件夹");
        normalTabl.add(typeLable);

        pathLable = new LangzhengTextField<String>();
        pathLable.setFieldLabel("位置");
        normalTabl.add(pathLable);

        infoLable = new LangzhengTextField<String>();
        infoLable.setFieldLabel("包含");
        normalTabl.add(infoLable);

        tabs.add(normalTabl);

        shareTabl = new TabItem();
        shareTabl.setText("共享");
        shareTabl.setEnabled(false);
        shareTabl.setLayout(new FormLayout());

        TextField<String> home = new TextField<String>();
        home.setFieldLabel("Home");
        home.setValue("800-555-1212");
        shareTabl.add(home);

        TextField<String> business = new TextField<String>();
        business.setFieldLabel("Business");
        shareTabl.add(business);

        TextField<String> mobile = new TextField<String>();
        mobile.setFieldLabel("Mobile");
        shareTabl.add(mobile);

        TextField<String> fax = new TextField<String>();
        fax.setFieldLabel("Fax");
        shareTabl.add(fax);

        tabs.add(shareTabl);

        panel.add(tabs);
        this.setWidth(350);
        // panel.addButton(new Button("Cancel"));
        // panel.addButton(new Button("Submit"));

        add(panel);
    }

    @Override
    protected void update() {
        FileModel fileModel = ChangeListItemEventContext.getFileModel();
        if (fileModel == null) return;
        this.setHeading(fileModel.getName() + "  属性");
        nameText.setValue(fileModel.getName());
        pathLable.setValue(EventUtils.getCurrentFullPath());
    }
}
